﻿; (function (window, undefined, $) {
    var submiting = false;
    $('#frmEdit').validator({
        rules: {
            // 自定义规则，如果通过返回true，否则返回错误消息
            //cusidcard: function (element, param, field) {
            //    var idtype = $("#Id").val();
            //    if (idtype == param[0]) {
            //        return /^.+$/.test($(element).val()) || "必填项";
            //    }
            //    return true;
            //}
        },
        fields: {
            '#Name': 'required',
            '#Code': 'required',
            '#lbMenu': 'required',
        },
        valid: function (form) {
            if (submiting) {
                return;
            }
            submiting = true;
            FormSubmit(form, function (res) {
                if (res.Status > 0) {
                    alert(res.Message);
                    window.location.href = "/Admin/Menu";

                }
                else {
                    alert(res.Message);
                }
                submiting = false;
            })
        }
    });

    util.GetParentName = function () {
        $.layer({
            type: 2,
            shade: [0],
            fix: false,
            title: '栏目信息',
            maxmin: true,
            offset: ['38', '18'],
            iframe: { src: options.MenuTreeUrl, scrolling: 'yes' },
            area: ['290px', '400px'],
            close: function (index) {
                //子窗口返回值 layer.getChildFrame('#name', index).val()
                //layer.msg('您获得了子窗口标记：' + layer.getChildFrame('#name', index).val(), 3, 1);
            }
            //end: function (index) {
            //    $('#lbParentName').html($('#UpperID').val());
            //}
        });
    };
    $("#btnSave").click(function (e) {
        $("#UpperID").val($("#UpperIDtree").val());

        //alert($("#UpperIDtree").find("option:selected").text());

        $("#frmEdit").submit();
    });
    $("#btnReturn").click(function (e) {
        window.location.href = "/Admin/Menu";
    });
    util.GetSequence = function (id, num) {
        var re = /^[0-9]*[0-9][0-9]*$/;
        if (!re.test(num)) {
            $('#' + id).val(0);
        }
    }
    util.GetNameE = function (id, num) {
        if (num == "") {
            $('#' + id).val($("#Name").val());
        }
    }
})(window, undefined, jQuery);